<template>
	<view class="">
		<uni-card title="添加设备" >
			<uni-forms style="margin-top:50rpx;">
				<uni-forms-item label="识别码:">
						<uni-easyinput v-model="IdentificationCode"  placeholder="请输入识别码"></uni-easyinput>
				</uni-forms-item>	
			</uni-forms>
					
		</uni-card>
	</view>
	<button class="zhi_button" @click="addAdviceMethods">添加</button>
</template>

<script setup>
	import {ref} from 'vue';
	import { addAdvice } from "../../api";
	import { uniToast,uniRouter } from '../../utils';
	let IdentificationCode =ref("");
	async function addAdviceMethods(){
	
		if(!IdentificationCode.value) return uniToast.toast("请填写设备码");
		try{
			let result = await addAdvice({code:IdentificationCode.value})
			console.log(result);
			if(result.code == 200){
				uniToast.toast("设备添加成功")
				uniRouter.back()
			}else{
				uniToast.toast("设备添加失败")
			}
		}catch(err){
			uniToast.toast("设备添加失败")
		}
		
	}
</script>

<style lang="scss">
	.uni-card{
		background:linear-gradient(180deg,  #f1f1f1,#9ef2a9);;
	}
	.uni-card__content{
		margin-top:40rpx;
	}
	.zhi_button{
		background: linear-gradient(45deg,  #9ef2a9,#9ef2a9);
		width:690rpx;
		position: absolute;
		bottom:200rpx;
		left:50%;
		transform: translate(-50%,0);
		color:#fff;
	}
</style>